package org.jpropelleralt.node.impl;

import org.jpropelleralt.node.Node;
import org.jpropelleralt.ref.Ref;
import org.jpropelleralt.transformer.Transformer;

/**
 * A {@link Transformer} from {@link Node}s to named {@link Ref}s
 * within them.
 */
public class RefNameTransformer implements Transformer<Node, Ref<?>> {

	private final String name;

	/**
	 * Create a {@link RefNameTransformer}
	 * @param name	The name of the {@link Ref} within the {@link Node}
	 */
	public RefNameTransformer(String name) {
		super();
		this.name = name;
	}

	@Override
	public Ref<?> transform(Node s) {
		return s.get(name);
	}

}
